package org.semanticflash.rdf.utils
{


	import com.bigflexlib.ds.container.zet.IRSet;
	import com.bigflexlib.ds.container.zet.impl.owSet;
	
	import flexunit.framework.TestCase;
	
	import org.semanticflash.rdf.triple.RDFTriple;
	import org.semanticflash.rdf.triple.RDFTriplePattern;
	import org.semanticflash.rdf.values.IRI;




	/**
	 * @private
	 * 
	 */
	public class RDFTestingUtilTest extends BasicTestBase
	{


		private var a:IRI = RDFTestingUtil.parseCharIRI( "a" );
		private var b:IRI = RDFTestingUtil.parseCharIRI( "b" );
		private var c:IRI = RDFTestingUtil.parseCharIRI( "c" );




		public function test_parseCharIRI( ):void
		{
			assertStrictlyEquals( 
				RDFTestingUtil.parseCharIRI( "a" ), 
				IRI.instance( RDFTestingUtil.URN_CHAR_NS + "a" )
				);
		}


		public function test_parseBindings( ):void
		{
		
		
			assertObjectsShallowStrictEqual( RDFTestingUtil.parseCharBindings( " Xa , Yb " ), { X:a, Y:b } );

			assertObjectsShallowStrictEqual( RDFTestingUtil.parseCharBindings( " " ), {  } );
		
		
		}

		
		public function test_parseTriplePattern( ):void
		{
			
			
			var abY:RDFTriplePattern = RDFTriplePattern.instance( a, b, "Y" );
			var aXY:RDFTriplePattern = RDFTriplePattern.instance( a, "X", "Y" );
			
			assertTrue(   
					RDFTestingUtil.parseCharTriplePattern( "abY" ).compare( abY ).isEqual
				);
			
			assertTrue(   
					RDFTestingUtil.parseCharTriplePattern( "aXY" ).compare( aXY ).isEqual
				);
			
		
		}
		

//		public function test_parseCharSolution( ):void
//		{
//		
//			
//			var sol1:RDFGPSolution = RDFTestingUtil.parseCharSolution( "abc, cde | Xa, Yb " );
//			var sol1b:RDFGPSolution = new RDFGPSolution( null , RDFTestingUtil.parseCharTriples( " abc, cde " ) , { X:a, Y:b }  );
//		
//			var sol2:RDFGPSolution = RDFTestingUtil.parseCharSolution( "abc " );
//			var sol2b:RDFGPSolution = new RDFGPSolution( null , RDFTestingUtil.parseCharTriples( " abc " )  );
//
//			var sol3:RDFGPSolution = RDFTestingUtil.parseCharSolution( " " );
//			var sol3b:RDFGPSolution = new RDFGPSolution(  );
//
//		
//		
//		
//			assertTrue( sol1.compare( sol1b ).isEqual );
//			assertTrue( sol2.compare( sol2b ).isEqual );
//		
//			assertFalse( sol1.compare( sol2b ).isEqual );
//			assertFalse( sol2.compare( sol1b ).isEqual );
//		
//			
//			assertTrue( sol3.compare( sol3b ).isEqual );
//		
//		
//		}


		public function test_parseCharTriple( ):void
		{
			
			
			assertStrictlyEquals(  RDFTestingUtil.parseCharTriple( "abc" )  , RDFTriple.instance( a, b, c )  );

			assertStrictlyEquals(  RDFTestingUtil.parseCharTriple( "a*c" )  , RDFTriple.instance( a, null, c )  );
		
			assertStrictlyEquals(  RDFTestingUtil.parseCharTriple( "a**" )  , RDFTriple.instance( a, null, null )  );
		
		
		}

		
		
		
		
		public function test_parseCharTriples( ):void
		{
		
		
			var abc:RDFTriple = RDFTestingUtil.parseCharTriple( "abc" );		
			var aaa:RDFTriple = RDFTestingUtil.parseCharTriple( "aaa" );		
			var bbb:RDFTriple = RDFTestingUtil.parseCharTriple( "bbb" );		
			var ccc:RDFTriple = RDFTestingUtil.parseCharTriple( "ccc" );		
			var a_a:RDFTriple = RDFTestingUtil.parseCharTriple( "a*a" );		
			
			var all:IRSet = owSet( [ abc, aaa, bbb, ccc, a_a ] );
		
			// the following should return an array containing only one triple
			var _abc:IRSet = RDFTestingUtil.parseCharTriples( "abc" );
			
			assertTrue( _abc.compare( owSet( [ abc ] ) )  );
			
			var all2:IRSet = RDFTestingUtil.parseCharTriples( "abc,aaa, bbb, c cc,    a*a   " );
			
			
			assertTrue( all2.compare( all ).isEqual );
			
		
		
		}



		public function test_parseCharTriples_empty( ):void
		{
			
			assertEquals( RDFTestingUtil.parseCharTriples("").size, 0  );		
			
			assertEquals( RDFTestingUtil.parseCharTriples(" ").size, 0  );		
		
		}		
		
		
		
		

		


		
	}


}